import { PREVIEW } from "cc/env"
import { StorageUtil } from "./util/StorageUtil"

export class Setting {

    //震动
    private static vibrateEnabled: boolean = true
    public static get VibrateEnabled(): boolean {
        return this.vibrateEnabled
    }
    public static set VibrateEnabled(v: boolean) {
        this.vibrateEnabled = v
        StorageUtil.setItem('vibrateEnabled', v)
    }

    //音效
    private static sfxEnabled: boolean = true       
    public static get SfxEnabled(): boolean {
        return this.sfxEnabled
    }
    public static set SfxEnabled(v: boolean) {
        this.sfxEnabled = v
        StorageUtil.setItem('sfxEnabled', v)
    }

    //音乐
    private static bgmEnabled: boolean = true
    public static get BgmEnabled(): boolean {
        return this.bgmEnabled
    }
    public static set BgmEnabled(v: boolean) {
        this.bgmEnabled = v
        StorageUtil.setItem('bgmEnabled', v)
    }

    public static init(): void {
        this.sfxEnabled = StorageUtil.getItem('sfxEnabled', true)
        this.bgmEnabled = StorageUtil.getItem('bgmEnabled', true)
        this.vibrateEnabled = StorageUtil.getItem('vibrateEnabled', true)
    }

}

if (PREVIEW) {
    globalThis.Setting = Setting
}